#ifndef ITERABLE_H
#define ITERABLE_H

#include <base/base.hpp>
#include <base/log.hpp>

namespace tbs::structs {

template<typename T>
class Iterable {
public:
  virtual T begin() NO_EXCEPT = 0;

  virtual T end() NO_EXCEPT = 0;
};

template<typename T>
class Iterator {
public:
  /**
   * @brief 下一个元素
   * @return
   */
  virtual Iterator<T> &next() = 0;

  /**
   * @brief 是否存在下一个元素
   * @return
   */
  virtual bool has_next() CONST = 0;

  /**
   * @brief 当前值
   * @return
   */
  virtual T &value() = 0;

  /**
   * @brief 源地址
   * @return
   */
  virtual CONST void *source() CONST = 0;

  template<typename V>
  CONST V *source_t() CONST;

  /**
   * @brief 当前位置
   * @return
   */

  virtual const size_t index() CONST = 0;

  /**
   * @brief 是否相等
   * @param other
   * @return
   */
  virtual bool equals(CONST Iterator<T> &other) CONST;

  bool operator!=(CONST Iterator<T> &other) CONST;

  Iterator<T> &operator++();

  T &operator*();

};

#include "inls/structs/ItreatorInl.cuh"

}// namespace tbs::structs

#endif// !ITERABLE_H

